package com.ost.kautilya.utils;

import com.ost.kautilya.utils.metrics.AbstractMetric;
import com.ost.kautilya.utils.metrics.Maximum;
import com.ost.kautilya.utils.metrics.Mean;
import com.ost.kautilya.utils.metrics.Minimum;
import com.ost.kautilya.utils.metrics.Population;
import com.ost.kautilya.utils.metrics.Totals;

public enum Metric {
	POP("n"), TOTAL("+"), MAX("<"), MIN(">"), MEAN("μ"), DISTINCT_COUNT("!");//, SD("σ"), RSD("%");
	private final String unit;

	private Metric(String u) {
		unit = String.valueOf(u);
	}

	public static enum DataType {
		LONG, DOUBLE
	}

	public static StatisticalMetric newMetric(Metric type, DataType dt) {
		AbstractMetric<?> metric = null;
		switch (type) {
		case POP:
			metric = new Population(DataType.LONG);
			break;
		case TOTAL:
			metric = new Totals(dt);
			break;
		case MAX:
			metric = new Maximum(dt);
			break;
		case MIN:
			metric = new Minimum(dt);
			break;
		case MEAN:
			metric = new Mean(dt);
			break;
		case DISTINCT_COUNT:
			metric = new DistinctCount(dt);
			break;
		/*case SD:
			metric = new StandardDeviation(dt);
			break;
		case RSD:
			metric = new RelationalStandardDeviation(dt);
			break;*/
		}
		if (metric != null) {
			metric.setType(type);
		}
		return metric;
	}

	public String asLabel() {
		return name();
	}

	public String unit() {
		return unit;
	}
}
